package com.glela.platform.mapper;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;

import com.glela.platform.model.Bank;
import com.glela.platform.model.UserBank;
import com.glela.platform.model.UserJournal;

public interface UserBankMapper {
	
	/**
	 * 查询用户银行卡列表
	 * @param userId
	 * @param pagelimit
	 * @param pageSize
	 * @return
	 */
	public List<UserBank> selectUserBankPage(@Param("userId")long userId, @Param("startIndex")int startIndex ,@Param("pageSize")int pageSize);
	
	/**
	 * 查询支付宝账户
	 * @param userId
	 * @return
	 */
	public UserBank selectUserBankAli(@Param("userId")long userId);

	/**
	 * 查询用户银行卡总数
	 * @param userId
	 * @return
	 */
	public int selectUserBankcount(Long userId);

	/**
	 * 删除银行卡
	 * @param userId
	 * @param id
	 * @return
	 */
	public int deleteUserBankById(@Param("userId")Long userId, @Param("id")int id);

	/**
	 * 新增银行卡
	 * @param userId
	 * @param name
	 * @param bankCard
	 * @param bankId
	 * @param bankBranchName
	 * @param idNumber 
	 * @param bankBranchId 
	 * @return
	 */
	public int insertUserBank(@Param("userId") Long userId, @Param("name") String name,
			@Param("bankCard") String bankCard, @Param("bankId") int bankId,
			@Param("bankBranchName") String bankBranchName, @Param("bankName")String bankName, 
			@Param("bankBranchId")int bankBranchId, @Param("idNumber")String idNumber);

	/**
	 * 用户提现
	 * @param userId
	 * @param orderSn
	 * @param money
	 * @param bankId
	 * @param comment
	 * @param status
	 * @return
	 */
	public int insertUserJournal(UserJournal userJournal);
	
	public int insertUserDrawings(@Param("userId") Long userId, @Param("orderSn") String orderSn,
			@Param("money") long money, @Param("bankId") int bankId, @Param("comment") String comment,
			@Param("status") int status,@Param("type") String type,@Param("journalId")int journalId);

	/**
	 * 用户提现（新增银行卡信息字段）
	 * zhangrnejie ------ 2017-09-08
	 *
	 * @return
	 */
	public int insertUserDrawingsNew(@Param("userId") Long userId, @Param("orderSn") String orderSn,
									 @Param("money") long money, @Param("bankId") int bankId, @Param("comment") String comment,
									 @Param("status") int status, @Param("type") String type, @Param("journalId") int journalId,
									 @Param("bankName") String bankName,@Param("name") String name,@Param("bankCard") String bankCard,
									 @Param("bankBranchName") String bankBranchName,@Param("createTime") String createTime);
	/**
	 * 默认银行卡
	 * @param userId
	 * @return
	 */
	public UserBank selectUserBankByIdLimitOne(Long userId);
	
	/**
	 * 查询合作银行
	 * @return
	 */
	public List<Bank> selectBankList();

	public Bank selectBankById(int bankId);
	
	public int selectUserAdvanceLimit();

	public UserBank selectBankByCardNo(String bankCard);

	public int updateUserBankStatus(@Param("status")int status, @Param("id")long id);

	public int updateUserAliInfo(@Param("name")String name, @Param("bankCard")String bankCard, @Param("userId")long userId);

	public UserBank queryUserBankByPrimaryId(@Param("id")int bankId);

	//按照创建时间查询最新的一条提现记录--------------zhangrenjie
    public Map<String,Object> queryUserDrawingsByCreateTime(@Param("userId")Long userId, @Param("bankId")int bankId, @Param("money")int money, @Param("journalId")int journalId, @Param("createTime") String time,@Param("type") String type);

    //根据用户id查询提现最新的一条记录
	public Map<String,Object> selectUserDrawingsNewByUserId(@Param("userId")Long userId);
}
